package com.leff.cards.entity;

import com.google.appengine.api.datastore.Entity;
import com.leff.cards.StoreWrapper;
import com.leff.cards.request.Request.Parameter;

public class Configuration extends EntityWrapper {

	public static final String KIND = "Configuration";
	
	public Configuration(Entity E) {
		super(E);
	}
	public Configuration() {
		super(KIND);
		setVersion(1);
	}
	
	public boolean checkVersion(int version) {
		
		long currVersion = getVersion();
		
		// If the version supplied is less than what we have stored - we need an upgrade!
		if(version < currVersion) {
			return true;
		}
		return false;
	}
	
	private long getVersion() {
		return (Long)get(Parameter.VERSION);
	}
	private void setVersion(int code) {
		put(Parameter.VERSION, code);
		StoreWrapper.store(this);
	}

	@Override
	public Object toJSON() {
		return null;
	}
	
}
